package bg.tu.varna.pms.model.communication;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.UUID;

import bg.tu.varna.pms.model.ContactStatus;
import bg.tu.varna.pms.model.LoginLocation;

public final class LoginMessage {
	private LoginMessage() {
	}

	public final static class Request implements Serializable {
		private static final long serialVersionUID = 8949118727506484381L;
		private String mUsername;
		private char[] mPassword;

		public String getUsername() {
			return mUsername;
		}

		public Request setUsername(String username) {
			this.mUsername = username;
			return this;
		}

		// TODO decryption
		public char[] getPassword() {
			return mPassword;
		}

		// TODO encryption
		public Request setPassword(char[] password) {
			this.mPassword = password;
			return this;
		}
	}

	public final static class Response implements Serializable {
		private static final long serialVersionUID = 5911789823143986628L;
		private boolean mSuccess;
		private final UUID mSessionID;
		private String mUsername;
		private String mNickname;
		private String mName, mSurname, mFamily;
		private Calendar mDateOfBirth;
		private ContactStatus mStatus;
		private String mStatusMessage;
		private final ArrayList<LoginLocation> mLoginLocations = new ArrayList<>();

		public Response() {
			mSessionID = UUID.randomUUID();
		}

		public boolean getSuccess() {
			return mSuccess;
		}

		public String getUsername() {
			return mUsername;
		}

		public String getNickname() {
			return mNickname;
		}

		public String getName() {
			return mName;
		}

		public String getSurname() {
			return mSurname;
		}

		public String getFamily() {
			return mFamily;
		}

		public Calendar getDateOfBirth() {
			return mDateOfBirth;
		}

		public ContactStatus getStatus() {
			return mStatus;
		}

		public String getStatusMessage() {
			return mStatusMessage;
		}

		public void setSuccess(boolean success) {
			mSuccess = success;
		}

		public void setUsername(String username) {
			mUsername = username;
		}

		public void setNickname(String nickname) {
			mNickname = nickname;
		}

		public void setName(String name) {
			mName = name;
		}

		public void setSurname(String surname) {
			mSurname = surname;
		}

		public void setFamily(String family) {
			mFamily = family;
		}

		public void setDateOfBirth(Calendar dateOfBirth) {
			mDateOfBirth = dateOfBirth;
		}

		public void setStatus(ContactStatus status) {
			mStatus = status;
		}

		public void setStatusMessage(String statusMessage) {
			mStatusMessage = statusMessage;
		}

		public UUID getSessionID() {
			return mSessionID;
		}

		public ArrayList<LoginLocation> getLoginLocations() {
			return mLoginLocations;
		}

		public void addLoginLocation(LoginLocation location) {
			mLoginLocations.add(location);
		}
	}
}
